package com.financial.sys.controller.bank;


import com.financial.common.constants.ResultCodeEnum;
import com.financial.common.vo.Result;
import com.financial.model.pojo.TBankCard;
import com.financial.sys.service.bank.TBankCardService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "银行卡管理")
@RestController
@RequestMapping("/user/bankcard")
public class BankCardController {

    @Autowired
    private TBankCardService tBankCardService;


    @ApiOperation("添加银行卡")
    @PostMapping("/add")
    public Result bankCardAdd(@ApiParam(name = "tBankCard",value = "用户更新对象") TBankCard tBankCard){
        int i=tBankCardService.addBankCard(tBankCard);
        if(i>0){
            return Result.ok().data(i);
        }
        return Result.error().message("银行卡添加失败!");
    }

    @ApiOperation("获取前台用户的银行卡信息")
    @PostMapping("/get/{accountId}")
    public Result selectUserInfo(@PathVariable(name = "accountId", required = false) String accountId){
        TBankCard tUserInfo=tBankCardService.selectUserBankCard(accountId);
        if(tUserInfo!=null){
            return Result.ok().data(tUserInfo);
        }
        return Result.setResult(ResultCodeEnum.USER_NOTFOUND);
    }

}
